<?php
/**
 * Created by PhpStorm.
 * User: linhongzhao
 * Date: 18-5-13
 * Time: 上午12:21
 */
require_once __DIR__ . '/../vendor/autoload.php';

echo '######' . PHP_EOL;
echo 'all cache type:' . PHP_EOL;
\EFrame\Cache::getCacheTypes();

$options = [
    'type' => 'array'
];

echo '######';
$item = new \EFrame\CacheItem('key1');
$item->set('value1');
echo 'item:' . PHP_EOL;
echo 'key: ' . $item->getKey() . PHP_EOL;
echo 'value: ' . $item->get() . PHP_EOL;

if (\EFrame\Cache::getInstance($options)->save($item)) {
    echo 'save: success' . PHP_EOL;
} else {
    echo 'save: fail' . PHP_EOL;
}

try {
    if (\EFrame\Cache::getInstance($options)->hasItem('key1')) {
        echo 'pool has key1: yes' . PHP_EOL;
    } else {
        echo 'pool has key1: no' . PHP_EOL;
    }
    $item = \EFrame\Cache::getInstance($options)->getItem('key1');
} catch (\Psr\Cache\InvalidArgumentException $e) {
    echo $e->getMessage();
}